<?php

namespace app\validate;
use think\Validate;


class User extends Validate
{
    protected $rule = [
        'username|用户账号' => 'require|min:2|max:20',
        'password|用户密码' => 'require|length:6:12',
        'repassword|学员密码' => 'require|confirm:password',
        'role|角色' => 'require|in:0,1',
        'email|学员邮箱' => 'require|email',    
        'status|状态' => 'require|in:0,1',  
    ];



    //注册  
    public function sceneAdd()
    {
        return $this->only(['username', 'password', 'repassword', 'email'])->append('username', 'unique:user');
    }
    //登陆
    public function sceneLogin(){
        return $this->only(['username','password','code']);

    }


    //编辑场景
    public function sceneEdit()
    {
        return $this->only(['status','role']); 
    }
}
